package file;


import java.io.*;
import java.util.UUID;

/**
 * @author: cuiyutian1
 * @date: 2021/9/9 20:55
 * @description:
 */
public class BufferWriteTest {

    public static void main(String[] args)  {
        String content = "This is the content to write into file\n";
        try( FileWriter fileWriter = new FileWriter("app.log");
             BufferedWriter bw = new BufferedWriter(fileWriter, 1024 * 8) )  {
            for (int i = 0; i < 10; i++) {
                String writeContent = getWriteContent();
                bw.write(writeContent);
                bw.newLine();
            }
            bw.flush();
        } catch (IOException e) {
            System.err.format("IOException: %s%n", e);
        }
    }

    public static String getWriteContent(){
        return UUID.randomUUID().toString().substring(0,4);
    }
}
